//
//  EducationTableViewCell.m
//  MyProject
//
//  Created by jiaming yan on 2017/9/12.
//  Copyright © 2017年 yanjiaming. All rights reserved.
//

#import "EducationTableViewCell.h"

@implementation EducationTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.editButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
}

-(void)setEducationArr:(NSArray *)educationArr{
    
    for (UIView *subViews in self.backView.subviews) {
        [subViews removeFromSuperview];
    }
    
    CGFloat beginHeight = 18;

    for (NSInteger i = 0 ; i < educationArr.count; i++) {
        EducationModel *model = educationArr[i];
        
        UIImageView *img = [[UIImageView alloc]initWithImage:IMAGE(@"圆")];
        img.frame = CGRectMake(15, beginHeight + 2*(i+1), 11, 11);
        [self.backView addSubview:img];
        
        UILabel *timeLab = [[UILabel alloc]initWithFrame:CGRectMake(41, beginHeight, kScreenWidth - 30 - 41 - 15, 18)];
        timeLab.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12];
        timeLab.textAlignment = NSTextAlignmentLeft;
        timeLab.textColor = UIColorFromRGB(0x485053);
        [self.backView addSubview:timeLab];
        timeLab.text = [NSString stringWithFormat:@"%zd年毕业",model.graduation];
        
        UILabel *labMust = [[UILabel alloc]initWithFrame:CGRectMake(41, timeLab.mj_y + timeLab.mj_h + 10, kScreenWidth - 30 - 41 - 15, 17)];
        labMust.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
        labMust.textAlignment = NSTextAlignmentLeft;
        labMust.textColor = UIColorFromRGB(0x485053);
        [self.backView addSubview:labMust];
        labMust.text = model.school;
        
        UILabel *detailLab = [[UILabel alloc]initWithFrame:CGRectMake(41, labMust.mj_y + labMust.mj_h + 10, kScreenWidth - 30 - 41 - 15, 17)];
        detailLab.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14];
        detailLab.textAlignment = NSTextAlignmentLeft;
        detailLab.textColor = UIColorFromRGB(0x485053);
        [self.backView addSubview:detailLab];
        detailLab.text = [NSString stringWithFormat:@"%@/%@",model.educationName,model.major];
        
        beginHeight =  detailLab.mj_y + detailLab.mj_h + 26;
    }
    
    self.backHeight.constant = beginHeight;
    if (educationArr.count == 0) {
        self.backHeight.constant = 60;
    }else{
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(19.5, 24 , 2, beginHeight - 20)];
        line.backgroundColor = UIColorFromRGB(0xD9F3F6);;
        [self.backView addSubview:line];
        [self.backView sendSubviewToBack:line];
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
